package net.lzzy.practices.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Course实体类，继承自BaseEntity，表示课程信息。
 * 该类使用了Lombok库的@Getter和@Setter注解来自动生成getter和setter方法，
 * 并使用了JPA注解来定义数据库表的映射关系。
 * @author AndyStern
 */
@Entity
@Getter
@Setter
public class Course extends BaseEntity{
    private String name;

    private String description;

    private String cover;

    private Date createTime;

    private Date updateTime;

    public boolean open;

    @ManyToOne
//    @JsonBackReference
    private User teacher;

    @ManyToMany
//    @JsonIgnore
    private List<User> students = new ArrayList<>();

    @OneToMany(mappedBy = "course")
    private List<Chapter> chapters = new ArrayList<>();

    @OneToMany(mappedBy = "course")
    private List<Applicant> applicants = new ArrayList<>();

    public Course(){
        createTime = new Date();
        updateTime = new Date();
    }

}